#include <gnome.h>
#include "perror_exit.h"
#ifndef _MONITOR_H_
# define _MONITOR_H_

typedef enum {
	MONITOR_ACTION_POPUP,
	MONITOR_ACTION_SCRIPT,
	MONITOR_ACTION_EMAIL,
} action_type;

union action_conf {
	void *popup;          // MONITOR_ACTION_POPUP
	char *script;         // MONITOR_ACTION_SCRIPT
	char *emailAddress;   // MONITOR_ACTION_EMAIL
};

struct monitor_action {
	action_type type;
	void(*handler)(char *msg);
	union action_conf conf;
};

typedef enum {
	MONITOR_TYPE_URL_WATCH,
	MONITOR_TYPE_DOMAIN_WATCH,
	MONITOR_TYPE_DOS,
	MONITOR_TYPE_COUNT
} monitor_type;

struct domain_conf {
	char *domain;
	//struct domain_entry *entry;
};

union monitor_conf_data {
	char *url;                 // URL Watch
	struct domain_conf domain; // Domain Watch
	double threshold;          // D.O.S.
};

typedef struct _monitor monitor;

struct monitor_conf {
	GtkWidget *(*form)(GtkWidget *, monitor *m);
	union monitor_conf_data confData;
};

struct _monitor{

	monitor_type type;
	char *title;
	char *about;


	gboolean active;
	int id;

	short(*w3ld_init)(w3lclient *w3lc,monitor *m);
	
	struct monitor_action action;
	struct monitor_conf conf;

};

GtkWidget *
conf_form_url_watch(GtkWidget *app, monitor *m);

GtkWidget *
conf_form_domain_watch(GtkWidget *app, monitor *m);

GtkWidget *
conf_form_dos(GtkWidget *app, monitor *m);

void
monitor_popup(char *msg);


short
watch_init_url(w3lclient *w3lc,monitor *m);

short
watch_init_domain(w3lclient *w3lc,monitor *m);

short
watch_init_dos(w3lclient *w3lc,monitor *m);


extern monitor monitors[];

#endif
